// rightView.js
import { WebContentsView } from 'electron'
import path from 'node:path'

const preloadPath = path.join(__dirname, '../preload/index.js');
const indexPath = path.join(__dirname, '../renderer/index.html');

const createRightView = (win, config) => {
  const rightView = new WebContentsView({
    webPreferences: {
      nodeIntegration: true,
      contextIsolation: true,
      preload: preloadPath,
    },
  });
  rightView.webContents.openDevTools();
  rightView.webContents.loadFile(indexPath);
  rightView.setBounds({ x: config.mainWidth, y: 0, width: config.toolBarWidth - 15, height: config.mainHeight });
  win.contentView.addChildView(rightView);

  return rightView;
};

export default createRightView;